<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.5"/>
<title>spips: xspips_eeprom_polled_example.c File Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
  $(window).load(resizeHeight);
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="HTML_custom.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><img alt="Logo" src="xlogo_bg.png"/></td>
  <td style="padding-left: 0.5em;">
   <div id="projectname">spips
   </div>
   <div id="projectbrief">Vitis Drivers API Documentation</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.5 -->
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Overview</span></a></li>
      <li><a href="annotated.html"><span>Data&#160;Structures</span></a></li>
      <li><a href="globals.html"><span>APIs</span></a></li>
      <li><a href="files.html"><span>File&#160;List</span></a></li>
      <li><a href="pages.html"><span>Examples</span></a></li>
    </ul>
  </div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
$(document).ready(function(){initNavTree('xspips__eeprom__polled__example_8c.html','');});
</script>
<div id="doc-content">
<div class="header">
  <div class="summary">
<a href="#func-members">Functions</a>  </div>
  <div class="headertitle">
<div class="title">xspips_eeprom_polled_example.c File Reference</div>  </div>
</div><!--header-->
<div class="contents">
<a name="details" id="details"></a><h2 class="groupheader">Overview</h2>
<div class="textblock"><p>This file contains a design example using the SPI driver (<a class="el" href="struct_x_spi_ps.html" title="The XSpiPs driver instance data. ">XSpiPs</a>) in polled mode and hardware device with a serial EEPROM device. </p>
<p>The hardware which this example runs on must have a serial EEPROM (Microchip 25XX320 or 25XX160) for it to run. This example has been tested with the SPI EEPROM on the EP4.5 ARM processor.</p>
<dl class="section note"><dt>Note</dt><dd></dd></dl>
<p>None.</p>
<pre>
 MODIFICATION HISTORY:</pre><pre> Ver   Who  Date     Changes
</p>
<hr/>
<p>
 1.00  sdm  03/09/10 First release
 1.00  sdm  10/25/11 Updated the chip select to be used to second chip select
       ms   04/05/17 Modified Comment lines in functions to
                     recognize it as documentation block for doxygen
                     generation and also modified filename tag to include
                     the file in doxygen examples.
 3.9   sb   07/05/23 Added support for system device-tree flow.
</pre> </div><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:a1d9197ec4b9bd96eae501456b5b12cd5"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="xspips__eeprom__polled__example_8c.html#a1d9197ec4b9bd96eae501456b5b12cd5">EepromRead</a> (<a class="el" href="struct_x_spi_ps.html">XSpiPs</a> *SpiPtr, u16 Address, int ByteCount, EepromBuffer Buffer)</td></tr>
<tr class="memdesc:a1d9197ec4b9bd96eae501456b5b12cd5"><td class="mdescLeft">&#160;</td><td class="mdescRight">This function reads from the serial EEPROM connected to the SPI interface.  <a href="#a1d9197ec4b9bd96eae501456b5b12cd5">More...</a><br/></td></tr>
<tr class="separator:a1d9197ec4b9bd96eae501456b5b12cd5"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a2f23357b0cfe111d80824b3bfacb8b22"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="xspips__eeprom__polled__example_8c.html#a2f23357b0cfe111d80824b3bfacb8b22">EepromWrite</a> (<a class="el" href="struct_x_spi_ps.html">XSpiPs</a> *SpiPtr, u16 Address, u8 ByteCount, EepromBuffer Buffer)</td></tr>
<tr class="memdesc:a2f23357b0cfe111d80824b3bfacb8b22"><td class="mdescLeft">&#160;</td><td class="mdescRight">This function writes to the serial EEPROM connected to the SPI interface.  <a href="#a2f23357b0cfe111d80824b3bfacb8b22">More...</a><br/></td></tr>
<tr class="separator:a2f23357b0cfe111d80824b3bfacb8b22"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a4a743c7f5b2fa3ac8c213a302f300bdd"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="xspips__eeprom__polled__example_8c.html#a4a743c7f5b2fa3ac8c213a302f300bdd">SpiPsEepromPolledExample</a> (<a class="el" href="struct_x_spi_ps.html">XSpiPs</a> *SpiInstancePtr, u16 SpiDeviceId)</td></tr>
<tr class="memdesc:a4a743c7f5b2fa3ac8c213a302f300bdd"><td class="mdescLeft">&#160;</td><td class="mdescRight">The purpose of this function is to illustrate how to use the <a class="el" href="struct_x_spi_ps.html" title="The XSpiPs driver instance data. ">XSpiPs</a> device driver in polled mode.  <a href="#a4a743c7f5b2fa3ac8c213a302f300bdd">More...</a><br/></td></tr>
<tr class="separator:a4a743c7f5b2fa3ac8c213a302f300bdd"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a840291bc02cba5474a4cb46a9b9566fe"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="xspips__eeprom__polled__example_8c.html#a840291bc02cba5474a4cb46a9b9566fe">main</a> (void)</td></tr>
<tr class="memdesc:a840291bc02cba5474a4cb46a9b9566fe"><td class="mdescLeft">&#160;</td><td class="mdescRight">Main function to call the Spi Eeprom example.  <a href="#a840291bc02cba5474a4cb46a9b9566fe">More...</a><br/></td></tr>
<tr class="separator:a840291bc02cba5474a4cb46a9b9566fe"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<h2 class="groupheader">Function Documentation</h2>
<a class="anchor" id="a1d9197ec4b9bd96eae501456b5b12cd5"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void EepromRead </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="struct_x_spi_ps.html">XSpiPs</a> *&#160;</td>
          <td class="paramname"><em>SpiPtr</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">u16&#160;</td>
          <td class="paramname"><em>Address</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>ByteCount</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">EepromBuffer&#160;</td>
          <td class="paramname"><em>Buffer</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>This function reads from the serial EEPROM connected to the SPI interface. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">SpiPtr</td><td>is a pointer to the SPI driver component to use. </td></tr>
    <tr><td class="paramname">Address</td><td>contains the address to read data from in the EEPROM. </td></tr>
    <tr><td class="paramname">ByteCount</td><td>contains the number of bytes to read. </td></tr>
    <tr><td class="paramname">Buffer</td><td>is a buffer to read the data into.</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>None.</dd></dl>
<dl class="section note"><dt>Note</dt><dd>None. </dd></dl>

</div>
</div>
<a class="anchor" id="a2f23357b0cfe111d80824b3bfacb8b22"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void EepromWrite </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="struct_x_spi_ps.html">XSpiPs</a> *&#160;</td>
          <td class="paramname"><em>SpiPtr</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">u16&#160;</td>
          <td class="paramname"><em>Address</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">u8&#160;</td>
          <td class="paramname"><em>ByteCount</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">EepromBuffer&#160;</td>
          <td class="paramname"><em>Buffer</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>This function writes to the serial EEPROM connected to the SPI interface. </p>
<p>This function is not designed to be a driver to handle all the conditions of the EEPROM device. The EEPROM contains a 32 byte write buffer which can be filled and then a write is automatically performed by the device. All the data put into the buffer must be in the same page of the device with page boundaries being on 32 byte boundaries.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">SpiPtr</td><td>is a pointer to the SPI driver instance to use. </td></tr>
    <tr><td class="paramname">Address</td><td>contains the address to write data to in the EEPROM. </td></tr>
    <tr><td class="paramname">ByteCount</td><td>contains the number of bytes to write. </td></tr>
    <tr><td class="paramname">Buffer</td><td>is a buffer of data to write from.</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>None.</dd></dl>
<dl class="section note"><dt>Note</dt><dd>None. </dd></dl>

</div>
</div>
<a class="anchor" id="a840291bc02cba5474a4cb46a9b9566fe"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int main </td>
          <td>(</td>
          <td class="paramtype">void&#160;</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Main function to call the Spi Eeprom example. </p>
<dl class="section return"><dt>Returns</dt><dd>XST_SUCCESS if successful, otherwise XST_FAILURE.</dd></dl>
<dl class="section note"><dt>Note</dt><dd>None </dd></dl>

<p>References <a class="el" href="xspips__eeprom__polled__example_8c.html#a4a743c7f5b2fa3ac8c213a302f300bdd">SpiPsEepromPolledExample()</a>.</p>

</div>
</div>
<a class="anchor" id="a4a743c7f5b2fa3ac8c213a302f300bdd"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int SpiPsEepromPolledExample </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="struct_x_spi_ps.html">XSpiPs</a> *&#160;</td>
          <td class="paramname"><em>SpiInstancePtr</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">u16&#160;</td>
          <td class="paramname"><em>SpiDeviceId</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>The purpose of this function is to illustrate how to use the <a class="el" href="struct_x_spi_ps.html" title="The XSpiPs driver instance data. ">XSpiPs</a> device driver in polled mode. </p>
<p>This test writes and reads data from a serial EEPROM. The serial EEPROM part must be present in the hardware to use this example.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">SpiInstancePtr</td><td>is a pointer to the Spi Instance. </td></tr>
    <tr><td class="paramname">SpiDeviceId</td><td>is the Device Id of Spi.</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>XST_SUCCESS if successful else XST_FAILURE.</dd></dl>
<dl class="section note"><dt>Note</dt><dd></dd></dl>
<p>This function calls functions which contain loops that may be infinite if interrupts are not working such that it may not return. If the device slave select is not correct and the device is not responding on bus it will read a status of 0xFF for the status register as the bus is pulled up. </p>

<p>References <a class="el" href="struct_x_spi_ps___config.html#a9b11063c0ae635e0284463e9edf0fdf8">XSpiPs_Config::BaseAddress</a>, <a class="el" href="xspips__eeprom__intr__example_8c.html#a1d9197ec4b9bd96eae501456b5b12cd5">EepromRead()</a>, <a class="el" href="xspips__eeprom__intr__example_8c.html#a2f23357b0cfe111d80824b3bfacb8b22">EepromWrite()</a>, <a class="el" href="group__spips.html#gabfabf86279474d10c04bfe97f3386a64">XSpiPs_CfgInitialize()</a>, <a class="el" href="group__spips.html#gac069eaeb884436a488dbf5d8d56b990e">XSPIPS_CLK_PRESCALE_64</a>, <a class="el" href="group__spips.html#gaf0a0da0e20b70ee21a3998117785638e">XSPIPS_FORCE_SSELECT_OPTION</a>, <a class="el" href="group__spips.html#ga70c86f3842f5996d9d7fc874466f4136">XSpiPs_LookupConfig()</a>, <a class="el" href="group__spips.html#ga1fbe2203de88e79aa3a6c7e70e2f3436">XSPIPS_MASTER_OPTION</a>, <a class="el" href="group__spips.html#gaaa797b9b8184e6f39b0c0038553e48d8">XSpiPs_SelfTest()</a>, <a class="el" href="group__spips.html#ga146ed84d7a6ab3b3f8961697bd78da60">XSpiPs_SetClkPrescaler()</a>, <a class="el" href="group__spips.html#ga4f14bfc3ddd296adb08843dbbe30a306">XSpiPs_SetOptions()</a>, and <a class="el" href="group__spips.html#ga1ef5af2211095df5692567fa4721a8d5">XSpiPs_SetSlaveSelect()</a>.</p>

<p>Referenced by <a class="el" href="xspips__eeprom__polled__example_8c.html#a840291bc02cba5474a4cb46a9b9566fe">main()</a>.</p>

</div>
</div>
</div><!-- contents -->
</div><!-- doc-content -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
	<p class="footer">&copy; Copyright 2015-2022 Xilinx, Inc. All Rights Reserved.</p>
	<p class="footer">&copy; Copyright 2022-2023 Advanced Micro Devices, Inc. All Rights Reserved.</p>
</div>
</body>
</html>
